<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'manager_root.jsp' starting page</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/assets/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/assets/vendor/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/assets/vendor/linearicons/style.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/assets/vendor/chartist/css/chartist-custom.css">
<!-- MAIN CSS -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/assets/css/main.css">
<!-- FOR DEMO PURPOSES ONLY. You should remove this in your project -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath }/assets/css/demo.css">
<!-- GOOGLE FONTS -->
<!-- ICONS -->
<link rel="apple-touch-icon" sizes="76x76"
	href="${pageContext.request.contextPath }/assets/img/apple-icon.png">
<link rel="icon" type="image/png" sizes="96x96"
	href="${pageContext.request.contextPath }/assets/img/favicon.png">
</head>

<body>
	<c:set var="roottype" value="root"></c:set>
	<c:set var="editortype" value="editor"></c:set>
	<div id="wrapper">
		<jsp:include page="top.jsp"></jsp:include>
		<c:choose>
			<c:when test="${sessionScope.Manager.utype == pageScope.roottype}">
				<jsp:include page="leftroot.jsp"></jsp:include>
			</c:when>
			<c:when test="${sessionScope.Manager.utype == pageScope.editortype}">
				<jsp:include page="lefteditor.jsp"></jsp:include>
			</c:when>
		</c:choose>
		<div class="main">
			<div class="container">
				<div class="row text-center">
					<ul id="myTab" class="nav nav-tabs">
						<li class=""><a
							href="${pageContext.request.contextPath }/manage/showUserQuery.do?
						querytype=queryalluser&currPage=1&field=null&kw=null">
								查询所有用户</a></li>
						<li class="dropdown"><a href="#" id="myTabDrop1"
							class="dropdown-toggle" data-toggle="dropdown"> 用户条件查询 <b
								class="caret"></b></a>
							<ul class="dropdown-menu" role="menu"
								aria-labelledby="myTabDrop1">
								<li><a href="#jmeter" tabindex="-1" data-toggle="tab">用户名查询</a></li>
								<li><a href="#ejb" tabindex="-1" data-toggle="tab">用户类别查询</a></li>
							</ul></li>
					</ul>
					<div id="myTabContent" class="tab-content">
						<div class="tab-pane fade" id="jmeter">
							<form class="navbar-form navbar-left" role="form"
								action="${pageContext.request.contextPath }/manage/showUserQuery.do?
						querytype=likequery&currPage=1&field=uname"
								method="post">
								<div class="input-group">
									<input type="text" value="" name="kw" class="form-control"
										placeholder="请输入用户名"> <span class="input-group-btn"><button
											type="submit" class="btn btn-primary">查询</button></span>
								</div>
							</form>
						</div>
						<div class="tab-pane fade" id="ejb">
							<form class="navbar-form navbar-left" role="form"
								action="${pageContext.request.contextPath }/manage/showUserQuery.do?
						querytype=other&currPage=1&field=utype"
								method="post">
								<div class="input-group">
									<select class="form-control" name="kw">
										<option value="root">管理员</option>
										<option value="editor">编辑</option>
										<option value="ordinary">普通用户</option>
									</select><span class="input-group-btn"><button type="submit"
											class="btn btn-primary">查询</button></span>
								</div>
							</form>
						</div>
					</div>
				</div>
				<c:if test="${!empty pb }">
						<div class="table-responsive">
							<table class=" table table-hover ">
								<caption></caption>
								<thead>
									<tr>
										<th>用户名</th>
										<th>真实名称</th>
										<th>出生日期</th>
										<th>用户类型</th>
										<th>用户状态</th>
										<th>用户操作</th>
									</tr>
								</thead>
								<tbody>
									<c:forEach items="${pb.list }" var="p">
										<tr>
											<td>${p.uname }</td>
											<td>${p.utname }</td>
											<td>${p.ubirthday }</td>
											<td>${p.utype }</td>
											<td>${p.uup }</td>
											<td>
												<a href="${pageContext.request.contextPath }/manage/UpdateAndDeleteUserServlet.do?actiontype=update&querytype=${requestScope.querytype }&currPage=${pb.currPage }&field=${requestScope.field }&kw=${requestScope.kw }&uid=${p.uid}" class="btn btn-default btn-sm"role="button">修改用户</a> 
												<c:choose>
													<c:when test="${p.uup == 1 }">
														<a href="${pageContext.request.contextPath }/manage/UpdateAndDeleteUserServlet.do?actiontype=uup&uup=${p.uup}&querytype=${requestScope.querytype }&currPage=${pb.currPage }&field=${requestScope.field }&kw=${requestScope.kw }&uid=${p.uid}" class="btn btn-primary btn-sm" role="button">销毁用户</a>
													</c:when>
													<c:when test="${p.uup == 0 }">
														<a href="${pageContext.request.contextPath }/manage/UpdateAndDeleteUserServlet.do?actiontype=uup&uup=${p.uup}&querytype=${requestScope.querytype }&currPage=${pb.currPage }&field=${requestScope.field }&kw=${requestScope.kw }&uid=${p.uid}" class="btn btn-success btn-sm" role="button">激活用户</a>
													</c:when>
												</c:choose>
												<c:choose>
													<c:when test="${p.ucomment == 1 }">
														<a href="${pageContext.request.contextPath }/manage/UpdateAndDeleteUserServlet.do?actiontype=ucommand&ucomment=${p.ucomment}&querytype=${requestScope.querytype }&currPage=${pb.currPage }&field=${requestScope.field }&kw=${requestScope.kw }&uid=${p.uid}" class="btn btn-primary btn-sm" role="button">禁止评论</a>
													</c:when>
													<c:when test="${p.ucomment == 0 }">
														<a href="${pageContext.request.contextPath }/manage/UpdateAndDeleteUserServlet.do?actiontype=ucommand&ucomment=${p.ucomment}&querytype=${requestScope.querytype }&currPage=${pb.currPage }&field=${requestScope.field }&kw=${requestScope.kw }&uid=${p.uid}" class="btn btn-success btn-sm" role="button">允许评论</a>
													</c:when>
												</c:choose>
												<c:choose>
													<c:when test="${p.uvote == 1 }">
														<a href="${pageContext.request.contextPath }/manage/UpdateAndDeleteUserServlet.do?actiontype=uvote&uvote=${p.uvote}&querytype=${requestScope.querytype }&currPage=${pb.currPage }&field=${requestScope.field }&kw=${requestScope.kw }&uid=${p.uid}" class="btn btn-primary btn-sm" role="button">禁止投票</a>
													</c:when>
													<c:when test="${p.uvote == 0 }">
														<a href="${pageContext.request.contextPath }/manage/UpdateAndDeleteUserServlet.do?actiontype=uvote&uvote=${p.uvote}&querytype=${requestScope.querytype }&currPage=${pb.currPage }&field=${requestScope.field }&kw=${requestScope.kw }&uid=${p.uid}" class="btn btn-success btn-sm" role="button">允许投票</a>
													</c:when>
												</c:choose>
											</td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>
						<center>
							<!-- 若是第一页 首页和上一页不展示 -->
							<c:if test="${pb.currPage!=1 }">

								<a
									href='${pageContext.request.contextPath }/manage/showUserQuery.do?
						querytype=${requestScope.querytype }&currPage=1&field=${requestScope.field }&kw=${requestScope.kw }'>[首页]
								</a>
								<a
									href='${pageContext.request.contextPath }/manage/showUserQuery.do?
						querytype=${requestScope.querytype }&currPage=${pb.currPage-1 }&field=${requestScope.field }&kw=${requestScope.kw }'>[上一页]</a>
							</c:if>

							<!-- 将所有的页码展示出来 -->
							<c:forEach begin="1" end="${pb.totalPage }" var="n">
								<!-- 若是当前页 不可点 -->
								<c:if test="${pb.currPage == n }">
				${n }
			</c:if>

								<!-- 若不是当前页 可点 -->
								<c:if test="${pb.currPage != n }">
									<a
										href="${pageContext.request.contextPath}/manage/showUserQuery.do?
						querytype=${requestScope.querytype }&currPage=${n }&field=${requestScope.field }&kw=${requestScope.kw }">${n }</a>
								</c:if>
							</c:forEach>
							<!-- 若是最后一页 尾页和下一页不展示 -->
							<c:if test="${pb.currPage!=pb.totalPage }">
								<a
									href='${pageContext.request.contextPath}/manage/showUserQuery.do?
						querytype=${requestScope.querytype }&currPage=${pb.currPage+1 }&field=${requestScope.field }&kw=${requestScope.kw }'>[下一页]</a>
								<a
									href='${pageContext.request.contextPath}/manage/showUserQuery.do?
						querytype=${requestScope.querytype }&currPage=${pb.totalPage }&field=${requestScope.field }&kw=${requestScope.kw }'>[尾页]
								</a>
							</c:if>
							第${pb.currPage }页/共${pb.totalPage }页
						</center>
				</div>
				</c:if>
			</div>
		</div>
	</div>
	<script
		src="${pageContext.request.contextPath }/assets/vendor/jquery/jquery.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/assets/vendor/bootstrap/js/bootstrap.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/assets/vendor/jquery-slimscroll/jquery.slimscroll.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/assets/vendor/jquery.easy-pie-chart/jquery.easypiechart.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/assets/vendor/chartist/js/chartist.min.js"></script>
	<script
		src="${pageContext.request.contextPath }/assets/scripts/klorofil-common.js"></script>
	<script>
		$(function() {
			$('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
				// 获取已激活的标签页的名称
				var activeTab = $(e.target).text();
				// 获取前一个激活的标签页的名称
				var previousTab = $(e.relatedTarget).text();
				$(".active-tab span").html(activeTab);
				$(".previous-tab span").html(previousTab);
			});
		});
	</script>
</body>
</html>
